<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateMessagesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('messages', function (Blueprint $table) {
            $table->bigIncrements('id');

            $table->string('message', '100')
                ->default('')
                ->comment('返回消息');

            $table->string('language', '10')
                ->default('zh')
                ->comment('消息类型');

            $table->unsignedMediumInteger('error_code')
                ->default(0)
                ->comment('消息码');

            // 联合索引
            $table->index(['error_code', 'language'], 'code_lan');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('messages');
    }
}
